﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

using IHISCETeim.Model;
using IHISCETeim.BLL;
using IHISCETeim.Library;
using FineUI;
using Newtonsoft.Json.Linq;
using Newtonsoft.Json;
using System.Data;

namespace IHISCETeim.Web.AgentSys.SvrMgr
{
    public partial class ReportMarketFailure : AgentPageBase
    {

        protected override Permission[] PowerKey
        {
            get
            {
                return new Permission[] { Permission.查看 };
            }
        }
        protected override string DWZRef
        {
            get { return "ReportMarketFailure"; }
        }

        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                this.FromDate.Text = DateTime.Now.ToString("yyyy-MM-01");
                this.ToDate.Text = Convert.ToDateTime(DateTime.Now.ToString("yyyy-MM-01")).AddMonths(1).AddDays(-1).ToString("yyyy-MM-dd");
            }
        }

        private void binddata()
        {
        //    this.rpData.DataSoure = dt;
        //    this.rpData.DataBind();
        }

        protected DataTable _dt = null;
        protected DataTable dt
        {
            get {
                if (_dt == null)
                {
                    _dt = AgentQltyReportController.GetMarketFailure(this.FromDate.Text, this.ToDate.Text);
                }
                return _dt;
            }
        }

        protected string GetTableHead()
        {
            string trRowString = "<th>项目</th>";
            foreach (DataRow dr in dt.Rows)
            {
                trRowString += string.Format("<th>{0}</th>", dr["agentname"]);
            }
            return trRowString;
        }

        protected string GetTableTbody()
        {
            string trRowString = "";
            string trRow1String = "";// "<td>保内机器</td>";
            string trRow2String = "";//"<td>机器故障次数</td>";
            foreach (DataRow dr in dt.Rows)
            {
                trRowString += "<tr>";
                trRowString += string.Format("<td>{0}</td>", dr["AgentName"]);
                trRowString += string.Format("<td>{0}</td>", dr["macNum"]);
                trRowString += string.Format("<td>{0}</td>", dr["faultnum"]);
                trRowString += "</tr>";
            }
            return trRowString;
        }

        protected void btnSearch_Click(object sender, EventArgs e)
        {

        }
    }
}